<?php
    require_once("header.php");
    require_once $_site->get_handlepath('device');

	$id = request('id',false,true,false,0);
	$type=request('type',false,true,false,1);
	$pid = request('pid',false,true,false,0);
	if(intval($id)>0){
		$device_obj=new device();
		$set_info=$device_obj->get_setinfo($id);
	}
	
	$rtn_type=array(1=>'挖机',2=>'线路',10=>'运距分类',3=>'机手',4=>'地块',5=>'司机',6=>'油罐',7=>'设备',8=>'员工',9=>'员工');
	$rtn_com=array(1=>'设备型号',2=>'距离',3=>'姓名',4=>'名称',5=>'姓名',6=>'备注',7=>'产权人姓名',8=>'姓名',9=>'姓名');
	
	$rtn_car=array('挖机','渣车','压路机','推土机','公用车辆','其他设备');
?>
<script type="text/javascript" charset="utf-8">
loader.file({
	plugin:['validform/main','dialog/main','my97/wdatepicker'],
	skincss:['list']
})

function agree(){
	$.post("/handle.php",$("#form1").serialize(),function(res){
		if(res.state){					
			parent.change();
			return;
		}
		alert(res.msg);
		},'json');            
}
</script>
<style type="text/css">
.table td a.hover{display: line-block;background: #60D277;color: #ffffff;padding:5px;}
</style>
</head>
<body>
	<div class="main">
      <form action="/handle.php" method="post" id="form1">
      <input type="hidden" name="h" value="device/car_setedit">
      <input type="hidden" name="id" value="<?php echo $id?>">
      <input type="hidden" name="pid" value="<?php echo $pid?>">
      <input type="hidden" name="type" value="<?php echo $type?>">      
		<table cellpadding="0" cellspacing="1" border="0" class="table">


			<tr>
			    <td width="80px;"><?php echo $rtn_type[$type].'编号'; ?><font color="red">*</font></td>			
				<td style="text-align: left">
				   <input type="text" name="code" value="<?php echo $set_info['code'];?>"> 
			     </td>							    
			</tr>		
			
			<?php if(7==$type){ ?>
			<tr>
			    <td>车型</td>			
				<td style="text-align: left">				    
				    <?php foreach($rtn_car as $vo){ ?>
				    <label><input type="radio" name="cartype" value="<?php echo $vo;?>" <?php if(empty($set_info) || $vo==$set_info['cartype']){ ?>checked<?php }?>><?php echo $vo;?></label>&nbsp;&nbsp;
				    <?php } ?>
				</td>			    		
			</tr>			
			<?php } ?>




            <?php if(2==$type || 10==$type){  ?>
                <tr>
                    <td>最短运距</td>
                    <td style="text-align: left">
                        <input type="number" name="yun_min" value="<?php echo $set_info['yun_min'];?>"> 米
                    </td>
                </tr>

                <tr>
                    <td>最大运距</td>
                    <td style="text-align: left">
                        <input type="number" name="yun_max" value="<?php echo $set_info['yun_max'];?>"> 米
                    </td>
                </tr>
            <?php }else{ ?>


			<tr>
			    <td><?php echo $rtn_com[$type];?></td>			
				<td style="text-align: left">
				    <input type="text" name="comment" value="<?php echo $set_info['comment'];?>">				    				    
				</td>			    		
			</tr>

            <?php } ?>
			
			<?php if(3==$type || 5==$type || 7==$type || 8==$type || 9==$type){  ?>
			<tr>
			    <td>电话</td>			
				<td style="text-align: left">
				    <input type="text" name="phone" value="<?php echo $set_info['phone'];?>">				    				    
				</td>			    		
			</tr>				
			<?php } ?>


			
			<tr>
			    <td>状态</td>			
				<td style="text-align: left">
				    <label><input type="radio" name="state" value="1" <?php if(empty($set_info) || 1==$set_info['state']){ ?>checked<?php }?>>开启</label>&nbsp;&nbsp;
				    <label><input type="radio" name="state" value="0" <?php if($set_info && 0==$set_info['state']){ ?>checked<?php }?>>禁用</label>
				</td>			    		
			</tr>			
		
			<tr>
			    <td>排序</td>			
				<td style="text-align: left">
				    <input type="text" name="sort" value="<?php echo $set_info['sort']?$set_info['sort']:0;?>">
				            数字越大越靠前
				</td>			    		
			</tr>		
			
				
			<tr>
				<td colspan="2" >
                      <input type="button" value="<?php echo $set_info?'修  改':'添  加' ?>" class="button1" onclick="agree()">&nbsp;&nbsp;                      
				</td>
			</tr>
		</table>
	</form>	
	</div>
</body>
</html>